// 首页
// http://82.156.34.12

// 登录
// http://82.156.34.12/login

// 接单
// http://82.156.34.12/api/getTaskFast


let token = Android.getMap("token")
localStorage.setItem("sid", token)


function getAndroidToken() {
    let token = localStorage.getItem("sid").replace(/^"|"$/g, '');
    return token
}
getAndroidToken()



// 接单
function getParameterHandler() {
    let token = parameter.getMap("token")
    let headers = {}
    let body = {
        "token": token,
        "t": new Date().getTime()
    }
    let strUrl = ``
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "POST",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()

// {
// 	"token": "5889d2bd-e045-46a0-8bcf-d27257af73cc",
// 	"t": 1724816630001
// }



// 处理返回数据
function getResponse() {
    let res = response.getMap("res")
    res = JSON.parse(res)

    let code = "500"
    let message = res['msg']

    if (res["code"] == 1) {
        code = "200"
    } else if (res["code"] == 0) {
        code = "500"
    } else {
        code = "300"
    }

    return {
        code: code,
        message: message,
        dataKey: "",
        dataValue: ""
    }
}
getResponse()

// {
// 	"code": 0,
// 	"msg": "暂无可接任务2",
// 	"time": "1724816780",
// 	"data": null
// }

// {"code":1,"msg":"请求成功","time":"1724816923","data":{"rows":[]}}